package com.kuqi.presenters;

import android.content.Context;
import android.os.Handler;
import androidx.lifecycle.Lifecycle;
import com.kuqi.core.ApplicationPersistent;
import com.kuqi.entitiy.Book;
import com.kuqi.entitiy.StorePageData;
import java.util.List;

public class BookStorePresenter extends BasePresenter {

    // 上下文
    private Context context;
    // 生命周期
    private Lifecycle lifecycle;
    // 回调页面控件handler
    private Handler callBackHandler;
    // callback的相关消息关键字
    public static final int FINISH_STORE_SEARCH = 10201;

    public List<String> promotionImages; // 轮播图片地址，其中 string e.g: “http://***/***/**.jpg”
    public List<Book> loveList;  // 言情
    public List<Book> travelList;  // 穿越
    public List<Book> masterList;  // 名著
    public List<Book> gameList;  // 网游

    // 构造函数
    public BookStorePresenter(Context context, Lifecycle lifecycle, Handler callBackHandler) {
        super(context, lifecycle);
        this.context = context;
        this.lifecycle = lifecycle;
        this.callBackHandler = callBackHandler;
    }

    /**
     * 调用来初始化查询相关书城显示数据
     * 由于功能迁移，查询功能放到splash界面进行预处理
     */
    public void searchStoreData(){
        //直接持久层获取预查寻的数据
        StorePageData data = ApplicationPersistent.getApplication().getStorePageData();
        promotionImages = data.getPromotionImages();
        loveList = data.getLoveList();
        travelList = data.getTravelList();
        masterList = data.getMasterList();
        gameList = data.getGameList();
        // 回调通知界面渲染
        callBackHandler.sendMessage(callBackHandler.obtainMessage(FINISH_STORE_SEARCH));
    }


}
